package com.qianya.system.face.util;

import cn.hutool.core.util.IdUtil;
import com.qianya.model.common.JWTUtil;
import com.qianya.model.pojo.sys.qo.SysLogQO;
import com.qianya.util.BaseCommon;

import javax.servlet.http.HttpServletRequest;

public class SyslogUtil {


    public static SysLogQO insertSyslog(SysLogQO sysLogQO) {

        //设置日志id
        sysLogQO.setId(IdUtil.simpleUUID());
        //得到token
        BaseCommon baseCommon = new BaseCommon();
        HttpServletRequest request = baseCommon.getRequest();
        String token = request.getHeader("token");
        //得到id 用户id
        String userId = JWTUtil.getUserId(token);
        sysLogQO.setUserid(userId);
        //得到username 用戶名
        String username = JWTUtil.getUsername(token);
        //设置用户姓名
        sysLogQO.setUsername(username);
        //设置状态
        sysLogQO.setLogType(2);


        return  sysLogQO;
    }



}
